package com.itheima_02;
/*

 */
import java.io.*;
import java.nio.Buffer;
import java.util.Properties;
import java.util.Set;

import static javafx.scene.input.KeyCode.R;

public class Test_01 {
    public static void main(String[] args) throws IOException {
        show();
    }

    private static void show() throws IOException {
        Properties p = new Properties();
        p.setProperty("filename","a.txt");
        p.setProperty("length","2009");
        p.setProperty("location","d:\\a.txt");

        //打印属性集对象

        System.out.println(p);

        String f = p.getProperty("filename");
        String l = p.getProperty("length");
        System.out.println(f);
        System.out.println(l);

        //遍历
        Set<String> s = p.stringPropertyNames();

        for (String s1 : s) {
            System.out.println(p.getProperty(s1));
        }

        p.store(new FileWriter("day01\\a.txt"),"save data");

        Properties p1 = new Properties();

        p1.load(new FileReader("F:\\Workspace\\day01\\a.txt"));

        System.out.println(p1);

        Set<String> s1 = p1.stringPropertyNames();

        for (String s2 : s) {
            String value = p1.getProperty(s2);
            System.out.println(s2+"---"+value);
        }
    }


}
